//
//  NetWorkTool.h
//  AAIM
//
//  Created by awh on 2019/11/22.
//  Copyright © 2019年 AAIM. All rights reserved.
//

#import <Foundation/Foundation.h>
#import "SLResultModel.h"

NS_ASSUME_NONNULL_BEGIN

//HTTP请求类别
typedef NS_ENUM(NSInteger,HttpRequestType) {
    HttpRequestGet,
    HttpRequestPost,
    HttpRequestPut,
    HttpRequestDelete,
};

typedef NS_ENUM(NSInteger,PageAction) {
    //首页
    PageActionNone
    
};

/**
 *  请求前预处理block
 */
typedef void(^PrepareExecuteBlock)(void);

typedef void(^SuccessBlock)(NSURLSessionDataTask * task, id responseObject);

typedef void(^FailureBlock)(NSURLSessionDataTask * task, NSError * error, id responseObject);

typedef void (^ResultResponseBlock)(SLResultModel *res);

@interface NetWorkTool : NSObject

+ (instancetype)shareInstance;
//用于请求app线上版本
-(void)requestAppVersionWithPath:(NSString *)url
                method:(HttpRequestType)method
           paramenters:(NSMutableDictionary *)params completion:(SuccessBlock)completion;

-(void)getAppInfoPath:(NSString *)url
                method:(HttpRequestType)method  completion:(SuccessBlock)completion;

-(void)requestWithPath:(NSString *)url
                method:(HttpRequestType)method
           paramenters:(NSMutableDictionary *)params completion:(ResultResponseBlock)completion;

-(void)requestPublicWithPath:(NSString *)url
     method:(HttpRequestType)method
paramenters:(NSMutableDictionary *)params completion:(ResultResponseBlock)completion;


#pragma mark -- 分页
-(void)page:(PageAction)action params:(NSDictionary *)params completion:(ResultResponseBlock)completion;

#pragma mark - socket

- (void)user:(NSInteger)userid isValidToken:(NSString *)token completion:(ResultResponseBlock)completion;


#pragma mark - 消息部分
// 获取服务器时间戳
- (void)currentTimestampCompleted:(ResultResponseBlock)completion;

// 获取离线消息
- (void)requestOfflineMessagesWithUid:(NSInteger)uid completed:(ResultResponseBlock)completion;

// 获取离线会话
- (void)offlineConversationsWithUid:(NSInteger)uid completed:(ResultResponseBlock)completion;

// 分页加载离线数据
- (void)offlineMessagesWithUid:(NSInteger)uid type:(NSString *)type uidOrGroupId:(NSInteger)uidOrGroupId pageIndex:(NSInteger)pageIndex pageSize:(NSInteger)pageSize completed:(ResultResponseBlock)completion;

// 批量删除指定id的离线消息
- (void)deleteOfflineMessagesWithUid:(NSInteger)uid messageids:(NSString *)ids  completed:(ResultResponseBlock)completion;

// 删除离线消息
- (void)deleteOfflineMessagesWithUid:(NSInteger)uid completed:(ResultResponseBlock)completion;

// 下载图片
- (void)downloadImageFile:(NSString *)src targetPath:(NSString *)path progress:(void (^)(NSProgress *downloadProgress))progress completion:(void (^)(NSError *error))completion;

// 下载语音文件
- (void)downloadVoiceFile:(NSString *)src targetPath:(NSString *)path progress:(void (^)(NSProgress *downloadProgress))progress completion:(void (^)(NSError *error))completion;


#pragma mark - 上传
// 上传图片
- (void)uploadImage:(UIImage *)image withURL:(NSString *)url withToken:(NSString *)token completion:(SuccessBlock)completion;

// 多张图片上传
- (void)uploadMoreImage:(UIImage *)image withURL:(NSString *)url withToken:(NSString *)token withType:(NSString *)type completion:(SuccessBlock)completion;

//聊天上传
//上传图片
-(void)uploadChattingImage:(UIImage*)image completion:(ResultResponseBlock)completion;

// 上传语音
- (void)uploadVoiceFile:(NSString *)path completion:(ResultResponseBlock)completion;

// 删除文件
- (void)upUserHeadImage:(UIImage *)image completion:(ResultResponseBlock)completion;


//获取临时token
-(void)requestTempTokenWithPath:(NSString *)url method:(HttpRequestType)method  completion:(SuccessBlock)completion;

@end

NS_ASSUME_NONNULL_END
